<?php
	class hotelGeoFunctionClass {
		protected $param = array(
								"apiKey" => null,
								"cid" => null,
								"locale" => null,
								"currencyCode" => null,
								"destinationId" => null,
								"arrivalDate" => null,
								"departureDate" => null,
								"occupancy" => null								
							);
							
		protected $wsdl = "http://api.ean.com/ean-services/ws/hotel/v3?wsdl&apiKey=t9grpd33pwudkegxpdrq6xp5";
		protected $objClient;
		protected $xmlParam;
		protected $soapvar;
		protected $objResponse;
		protected $response;
		protected $hotelGeo;
		protected $globalResult = array();
		
		protected function setXmlparam(){	
			$this->xmlParam = '<v3:getGeoLocation>
								 <LocationInfoRequest>
									<apiKey>t9grpd33pwudkegxpdrq6xp5</apiKey>
									<cid>55505</cid>
									<minorRev>9</minorRev>
									<customerIpAddress></customerIpAddress>
									<customerSessionId></customerSessionId>
									<customerUserAgent></customerUserAgent>
									<locale>en_US</locale>
									<currencyCode>USD</currencyCode> 
									<destinationString>candidasa</destinationString>
									<type>1</type>
								 </LocationInfoRequest>
							  </v3:getGeoLocation>';
		}
		
		protected function getdataParam(){
			$this->objClient = new SoapClient($this->wsdl, array('trace' => true,'exceptions' => 0,'features'=>SOAP_SINGLE_ELEMENT_ARRAYS, 'encoding' => 'UTF-8'));
			$this->setXmlparam();
			$this->soapvar = new SoapVar($this->xmlParam, XSD_ANYXML);
			$this->objResponse = $this->objClient->__soapCall("getGeoLocation", array($this->soapvar));
		}
	
		protected function setSimpleXml(){
			$this->response = $this->objClient->__getLastResponse();
			$xml = simplexml_load_string(htmlspecialchars_decode($this->response), NULL, NULL, "http://schemas.xmlsoap.org/soap/envelope/");
			$xml->registerXPathNamespace('soapenv', 'http://schemas.xmlsoap.org/soap/envelope/');
			$xml->registerXPathNamespace('ns1', 'http://v3.hotel.wsapi.ean.com/');
			$result = $xml->xpath('//ns1:getGeoLocationResponse');
			$result = $result[0]->LocationInfoResponse;
			$this->hotelGeo = $result;
		}
		
		public function setParam($apiKey, $cid, $locale, $currencyCode,$destinationId, $arrivalDate, $departureDate, $occupancy){
			$this->param = array(
								"apiKey" => $apiKey,
								"cid" => $cid,
								"locale" => $locale,
								"currencyCode" => $currencyCode,
								"destinationId" => $destinationId,
								"arrivalDate" => $arrivalDate,
								"departureDate" => $departureDate,
								"occupancy" => $occupancy								
							);
					
			$this->getdataParam();
			$this->setSimpleXml();
		}
		
		public function gethotelGeo(){
			$geo = $this->hotelGeo;
				
			$this->globalResult[] = (object)array(
									"customerSessionId" => (string)$geo->customerSessionId,
									"destinationId" => (string)$geo->LocationInfos->LocationInfo->destinationId,
									"active" => (string)$geo->LocationInfos->LocationInfo->active,
									"type" => (string)$geo->LocationInfos->LocationInfo->type,
									"city" => (string)$geo->LocationInfos->LocationInfo->city,
									"stateProvinceCode" => (string)$geo->LocationInfos->LocationInfo->stateProvinceCode,
									"countryCode" => (string)$geo->LocationInfos->LocationInfo->countryCode,
									"countryName" => (string)$geo->LocationInfos->LocationInfo->countryName,
									"code" => (string)$geo->LocationInfos->LocationInfo->code,
									"geoAccuracy" => (string)$geo->LocationInfos->LocationInfo->geoAccuracy,
									"locationInDestination" => (string)$geo->LocationInfos->LocationInfo->locationInDestination,
									"latitude" => (string)$geo->LocationInfos->LocationInfo->latitude,
									"longitude" => (string)$geo->LocationInfos->LocationInfo->longitude,
									"refLocationMileage" => (string)$geo->LocationInfos->LocationInfo->refLocationMileage,
									"activePropertyCount" => (string)$geo->LocationInfos->LocationInfo->activePropertyCount
									
			);
		
			return 	$this->globalResult;
		}
		
	}
	
	$hotelGeoFunction = new hotelGeoFunctionClass();
	$hotelGeoFunction->setParam("t9grpd33pwudkegxpdrq6xp5","55505","en_US","USD","6596BFE0-C9B1-4789-B7D1-9ACA0D4FEFE9","09/04/2013","09/05/2013","2");
?>
<pre><?php print_r($hotelGeoFunction->gethotelGeo()); ?></pre>